import { request } from "@/utils";

export function LoginService(data: any) {
  return request.post({
    url: "/user/login",
    data,
  });
}

export function LogoutService() {
  return request.post({
    url: "/user/logout",
  });
}

export function GetUserListService() {
  return request.get({ url: "/user" });
}

export function GetUserSearchService(data: any) {
  return request.get({
    url: "/user/search",
    params: {
      ...data,
    },
  });
}

export function GetUserByIdService(id: string | number) {
  return request.get({ url: "/user/" + id });
}

export function UpdatedUserInfoService(data: any) {
  return request.patch({ url: "/user", data });
}

/**
 * 注册用户
 * @path /user
 * @param data 注册的数据
 * @returns
 */
export function RegisterUserService(data: any) {
  return request.post({ url: "/user", data });
}
/**
 * 删除用户
 * @path /user
 * @param data 用户ID
 * @returns
 */
export function DeleteUserService(id: any) {
  return request.delete({ url: "/user/" + id });
}

/**
 *
 * @param data 用户数据
 * @returns
 */
export function ReadUserService(data) {
  return request.post({
    url: "/user/read",
    data,
  });
}

// 获取菜单
export function GetMenuService(ids?: string) {
  if (ids) {
    return request.get({ url: "/menu?ids=" + ids });
  } else {
    return request.get({ url: "/menu" });
  }
}

// 修改菜单
export function PatchMenuService(data: any) {
  return request.patch({
    url: "/menu",
    data,
  });
}
// 增加菜单
export function PostMenuService(data: any) {
  return request.post({
    url: "/menu",
    data,
  });
}
// 删除菜单
export function DeleteMenuService(data: any) {
  return request.delete({ url: "/menu", data });
}
// GetDepartmentService 获取部门
export function GetDepartmentService(name = "") {
  return request.get({
    url: "/department?name=" + name,
  });
}
// PostDepartmentService 增加部门
export function PostDepartmentService(data: any) {
  return request.post({
    url: "/department",
    data,
  });
}
// PatchDepartmentService 修改部门
export function PatchDepartmentService(data: any) {
  return request.patch({
    url: "/department",
    data,
  });
}

// DeleteDepartmentService 删除部门
export function DeleteDepartmentService(data: any) {
  return request.delete({
    url: "/department",
    data,
  });
}
